<?php
#--------------------------------------------------
# SYNCHRONIZE SCHEDULE
#--------------------------------------------------
include_once ("./dataAccess/classes/Property.php5");
include_once ("./dataAccess/dao/PropertyDAO.php5");

if (!empty($teams)){
	$propDao = new PropertyDAO();
	$i = 0;	
	$synchronize .= "<script language=\"javascript\" type=\"text/javascript\">";
	foreach ($teams as $team1){
		// lade property
		$property = $propDao->findByKey($team1->liga."_".$team1->saison);
		if (!empty($property)){
			// regeln auseinander nehmen
			$now = date("D");
			if ($now != $property->ist){
				// updaten
				$property->ist=$now;
				$property->fixdate=date("Y-m-d H:i:s");
				$property->updated = 1;
				if ($i > 0)
					$requestString .="||";
				$requestString .= $team1->liga."::".$team1->id."::".$team1->klasse;
			} else {
				// updaten
				$property->ist=$now;
				$property->updated = 0;
				$synchronize .= "";
			}
			$propDao->update($property);
		}
		$i++;
	}
	if (strlen(trim($requestString)) > 0){
		$synchronize .= "\nvar sync = new Synchronizer('".$requestString."', '".$team->saison."', 'ajaxhandler/loadSpielplan.php5');";
		$synchronize .= "sync.send();";
	}
	$synchronize .= "</script>";
} else {
	$synchronize = " ";
}

?>
